#ifndef GRIPPER_NODE
#define GRIPPER_NODE

#include <ros/ros.h>
#include <threemxl/C3mxlROS.h>
#include <XMLConfiguration.h>
#include <threemxl/dxlassert.h>
#include "topic/topic.h"
#include "comm/gripper_msg.h"
#include "config.h"

#define GRIPPER_PWM_CLOSED		-0.3
#define GRIPPER_PWM_OPEN		0.2

class GripperNode
{
private:
	ros::NodeHandle nh_;
	ros::Subscriber motor_sub_;
	ros::Publisher status_pub_;
	ros::Time timestamp_;

	LxSerial serial_port_;	// serial port interface
	C3mxlROS *motor_;

	int gripper_cstate, gripper_fstate;
public:
	GripperNode();
	~GripperNode();

	/**
	 * Handle incoming messages for the gripper.
	 * @param	msg	expected state for the gripper.
	 */
	void gripperCallback(const comm::gripper::ConstPtr &msg);

	/**
	 * Initialize motor parameters.
	 */
	void init();

	/**
	 * Spin node.
	 */
	void spin();
};


#endif
